# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Toolybird <toolybird at tuta dot io>

pkgname=ocaml-augeas
pkgver=0.6
pkgrel=2
pkgdesc="OCaml bindings for Augeas"
arch=(loong64 x86_64)
url="https://people.redhat.com/~rjones/augeas/"
license=(LGPL-2.0-or-later)
depends=(
  augeas
  glibc
)
makedepends=(
  ocaml
  ocaml-findlib
)
source=(
  https://people.redhat.com/~rjones/augeas/files/$pkgname-$pkgver.tar.gz{,.sig}
  $pkgname-0.6-options.patch
  $pkgname-0.6-ocaml4.patch
)
sha256sums=('8aba99ddacd08768ebeef4a2138361d13b41a30317fce7503140cd86a1307611'
            'SKIP'
            'f6e5cbe28c72f44f69f7fd9820281ae170ab95cdab8c713bf2e20f36a257b781'
            '015d419b92ab46996689559b8b95f4748e5189f861fe6590b850acc8eedc8873')
validpgpkeys=(F7774FB1AD074A7E8C8767EA91738F73E1B768A0) # Richard W.M. Jones <rjones@redhat.com>

prepare() {
  # patches from upstream (for which no new release was made because reasons...): http://git.annexia.org/?p=ocaml-augeas.git
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-0.6-options.patch
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-0.6-ocaml4.patch
}

build() {
  cd $pkgname-$pkgver

  export CFLAGS+=" -ffat-lto-objects"
  ./configure
  make -j1
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  cd $pkgname-$pkgver

  # install stublibs dir, as ocamlfind does not do that and we need it to not have ocamlfind run ldconfig
  install -vdm 755 "$pkgdir"/usr/lib/ocaml/stublibs
  OCAMLFIND_DESTDIR="$pkgdir/usr/lib/ocaml" make install
}
